//
//  CollectionModel.m
//  sensen_ios
//
//  Created by mc on 16/2/29.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "CollectionModel.h"

@implementation CollectionModel

- (id)initContentWithDic:(NSDictionary *)jsonDic {
    self = [super init];
    if (self != nil) {
        [self setAttributes:jsonDic];
        NSArray *tmpArray;
        _img = [NSMutableArray arrayWithCapacity:1];
        tmpArray = jsonDic[@"img"];
        if (![jsonDic[@"img"] isKindOfClass:[NSNull class]]){
            for (NSString *url in tmpArray) {
                NSString *str = [NSString stringWithFormat:@"%@%@",BOYE_PICTURE_URL,url];
                [_img addObject:str];
            }
        }else if([jsonDic[@"img"] isKindOfClass:[NSNull class]]){
            _img = nil;
        }
        
        
        
        id userInfoDic = jsonDic[@"user_info"];
        if (![userInfoDic isKindOfClass:[NSNull class]]) {
            userInfoDic = (NSDictionary *)userInfoDic;
            NSString *head = userInfoDic[@"head"];
            
            
            
            if ([head checkPositiveInteger]) {
                _authorImage = [NSString stringWithFormat:@"%@%@",BOYE_PICTURE_URL,head];
            }else{
                _authorImage = head;
            }

            _nickname = userInfoDic[@"nickname"];
        }

        
        
    }
    return self;
}


@end
